//
//  TransfersController.h
//  SolarSeek
//
//  Created by Erick Fejta on 05/02/01.
//  Copyright 2005 Erick Fejta. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "EnumTypes.h"

@class ConnectionsIdentifier;
@class PeerConnectionsController;
@class ServerConnection;
@class ShareController;
@class SharePeer;
@class SolarSeekEngine;
@class Transfer;
@class TransferDownload;
@class TransfersQueue;
@class Peer;

@interface TransfersController : NSObject {
	SolarSeekEngine *_engine;
	ConnectionsIdentifier *_connectionsIdentifier;
	ServerConnection *_serverConnection;
	PeerConnectionsController *_peerConnectionsController;
	ShareController *_shareController;
	TransfersQueue *_transfersQueue;

	NSMutableDictionary *_tokensTransferIncomingRequested;
	NSMutableSet *_transferConnectionsSet;

	NSMutableSet *_transfersManuallyStopped;
	NSMutableSet *_transfersSet;
	NSMutableSet *_transfersWaitingForConnection;
	NSMutableDictionary *_tokensFoldersDownloading;
	
	Transfer *_transferCreated,
			 *_transferFailed,
			 *_transferFinished,
			 *_transferRemoved,
			 *_transferStopped,
			 *_transferStarted;
}

- (id)initWithEngine:(SolarSeekEngine *)engine;

- (unsigned)countTransfersAllowed;
- (unsigned)countTransfersCurrent;
- (unsigned)countTransfersQueued;

- (Transfer *)transferCreated;
- (Transfer *)transferFailed;
- (Transfer *)transferFinished;
- (Transfer *)transferRemoved;
- (Transfer *)transferStopped;
- (Transfer *)transferStarted;

- (NSArray *)transfersAll;
- (NSArray *)transfersActive;
- (NSArray *)transfersQueued;

- (TransfersQueue *)transfersQueue;

- (void)downloadFolderOfShare:(SharePeer *)share;
- (NSSet *)downloadShares:(id)members;	//must respond to objectEnumerator like NSArray or NSSet
- (TransferDownload *)downloadShare:(SharePeer *)file;
- (void)deleteTransfer:(Transfer *)transfer;
- (void)stopTransfer:(Transfer *)transfer;
- (void)requestPlaceInQueueForTransfer:(Transfer *)t;

- (BOOL)loadDownloadFromFile:(NSString *)file;
- (BOOL)saveDownload:(TransferDownload *)download toFile:(NSString *)file;


- (NSSet *)transfersForPeer:(Peer *)p;
- (NSSet *)transfersWithType:(TransferType)type;
- (NSSet *)transfersForPeer:(Peer *)p withType:(TransferType)type;

@end
